const Mock = require('mockjs')
const user = require('./user')
const list = require('./list')
const mocks = [
  ...user,
  ...list
//   ...infor,
]
function XHR2ExpressReqWrap(respond) {
    return function(options) {
      let result = null
      if (respond instanceof Function) {
        const { body, type } = options
        result = respond({
          method: type,
          body: JSON.parse(body),
        //   query: param2Obj(url)
        })
      } else {
        result = respond 
      }
      return Mock.mock(result)
    } 
  }
for (const i of mocks) {
    Mock.mock(new RegExp(i.url), i.type || 'get', XHR2ExpressReqWrap(i.response))
  }
module.exports = {
    mocks
  }